﻿<%--<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<CRM.Models.TrainingsRequests>" %>--%>
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<CRM.Database.Model.TrainingsRequests>" %>
<%@ Import Namespace="CRM.Resourses" %>

<%
    var participantsCol = new CRM.Database.Model.TrainingsParticipantsCollection();
    var statusesCol = new CRM.Database.Model.TrainingParticipantsStatusesCollection();
%>

<% Html.DevExpress().GridView(settings =>
                                    {
                                        settings.Name = "gdTrainingsParticipant";
                                        settings.KeyFieldName = "IdTrainingsParticipant";
                                        settings.CallbackRouteValues = new { Controller = "TC", Action = "TrainingsRequestDetailsPartal", idTrainingsRequest = Model.IdTrainingsRequest };
                                        settings.SettingsPager.PageSize = 20;
                                        settings.Width = 600;
                                        settings.SettingsEditing.Mode = GridViewEditingMode.EditFormAndDisplayRow;
                                        
                                        settings.Columns.Add(column =>
                                                                 {
                                                                     column.Caption = Resourses.Name;
                                                                     column.FieldName = "ParticipantName";
                                                                     //settings.Width = 100;
                                                                 });

                                        settings.Columns.Add(column =>
                                                                 {
                                                                     column.Caption = Resourses.TrainingsPosition;
                                                                     column.FieldName = "ParticipantPosition";
                                                                     //settings.Width = 100;
                                                                 });
                                        
                                        settings.Columns.Add(column =>
                                                                 {
                                                                     column.FieldName = "IdTrainingsParticipantsStatus";
                                                                     column.Caption = Resourses.TrainingParticipantsStatus;
                                                                     column.ColumnType = MVCxGridViewColumnType.ComboBox;
                                                                     column.ReadOnly = false;
                                                                     var comboBoxProperties = column.PropertiesEdit as ComboBoxProperties;
                                                                     if (comboBoxProperties != null)
                                                                     {
                                                                         comboBoxProperties.DataSource = statusesCol.TrainingParticipantsStatusesList;
                                                                         //comboBoxProperties.DataSource = DB.GetLocalizedTrainingParticipantsStatusesNames(Thread.CurrentThread.CurrentCulture.ToString());
                                                                         comboBoxProperties.TextField = "LocalizedName";
                                                                         comboBoxProperties.ValueField = "IdTrainingParticipantsStatus";
                                                                         comboBoxProperties.ValueType = typeof (int);
                                                                     }
                                                                 });
                                    }).Bind(participantsCol.GetParticipantsByRequest(Model)).GetHtml();
                                    //}).Bind(DB.GetTrainingsParticipantsByRequest(Model)).GetHtml();
%>